package dao

import "alan-snippet/internal/models"


func GetUserByEmail(email string) (*models.User,error){
	var user models.User
	err := DB.Where("email=?", email).First(&user).Error
	if err != nil {
		return nil,err 
	}
	return &user,nil
}

func GetUserById(id int) (*models.User,error){
	var user models.User
	err := DB.Where("id=?", id).First(&user).Error
	if err != nil {
		return nil,err 
	}
	return &user,nil
}

func CreateUser(user *models.User) (*models.User,error){
	err := DB.Create(user).Error
	if err != nil {
		return nil,err
	}
	return user,nil
}
